//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XAppFrame.h>
///	@path	~/src/appear/xwin/
///	@date	2008/10/10
///	@desc	.

#pragma once

#include "xeres.h"

#include "lib/utilities/time.h"

#include "gui/xgui/XFrame.h"

#include "appear/xwin/FrameComposition.h"

namespace xeres {

	/*! 
		\class	XAppFrame
		\brief	
	*/
	class XAppFrame : public XFrame
	{
	public:

		/// \ctor
		XAppFrame( void );

		/// \ctor
		XAppFrame( const Rect<int>& placement );

		/// \ctor
		XAppFrame( const Pair<int>& size );

		/// \dtor
		virtual ~XAppFrame( void );

		DECL_IOBJECT_CLASS_DYNAMIC( XAppFrame , XFrame );

	public:

		/// \name XGui Component Attributes
		//@{

		/// \brief	Set parent component.
		virtual bool SetParent( RefWeak<IGuiForm> parent );

		/// \brief	Call when close window.
		virtual void OnClose( void );

		/// \brief	IsTickable
		virtual bool IsTickable( void );

		/// \brief	Set frame edge.
		virtual void SetFrameEdge( const Pair<int>& edge );

		/// \brief	Get frame edge.
		virtual const Pair<int>& GetFrameEdge( void );
		
		//@}

		/// \name Presentation Manipulation
		//@{

		/// \brief	Tick update.
		virtual void Tick( Updater& updater , float dTime );

		/// \brief	Draw GUI, accelerated method, draw to attached composite texture.
		virtual void Draw( RenderContext& rc , FrameComposition& fc );

		/// \brief	Control how to composite the frame.
		virtual void OnComposite( RenderContext& rc , FrameComposition& fc );

		//@}

		/// \name XFrame Effect Interface
		//@{

		/// \brief	Attach effect.
		virtual bool AttachEffect( RefWeak<IGuiEffect> effect , function<void()> affterEffect );

		/// \brief	Get effect (return 0 while no effect attached).
		virtual RefWeak<IGuiEffect> GetEffect( void );

		//@}

	protected:

		// @data
		Ref<CCompositeTexture>		m_texture;
		Ref<IGuiEffect>				m_effect;
		function<void()>			m_afterEffect;
		Pair<int>					m_areoEdge;
		Time						m_lastUpdate;
	};

} // namespace xeres
